﻿using EMRView;
using HC.View;
using EMRView.Extensions.HCAttribute;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace EMRView.Extensions.Command.StandardCommand.Table
{

    [Command(CommandType.表格, "InsertTable", "插入表格")]
    public class InsertTableCommand : BaseCommand
    {
        public override Icon CommandIcon
        {
            get
            {
                return Properties.HCResource.插入表格;
            }
        }


        public override object Execute(HCEmrView _view, bool showDefaultUI = false, params object[] para)
        {
            frmInsertTable vFrmInsertTable = new frmInsertTable();
            vFrmInsertTable.ShowDialog();
            if (vFrmInsertTable.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                HCRichData vTopData = _view.ActiveSectionTopLevelData() as HCRichData;
                DeTable vTable = new DeTable(vTopData, vFrmInsertTable.RowCount, vFrmInsertTable.ColCount, vTopData.Width);
                _view.InsertItem(vTable);
                return vTable;
            }
            else
            {
                return null;
            }
        }

        public override void InitControl(object control)
        {

        }
    }
}
